<template>
  <div class="main">
    <div class="heard">
      <div class="nav"><a></a></div>
      <h2 class="pag_title" @click="handleHome">提交订单</h2>
    </div>
    <section>
      <div
        class="address"
        @click="model = true"
        v-if="addressList.length != 0 ? true : false"
      >
        <div class="no-address-con" style="padding: 0; text-align: left">
          <p>
            <i style="font-size: 16px; color: #333; font-weight: bold">{{
              addressList[0].name
            }}</i>
            <i style="margin-left: 15px; font-size: 14px; color: #333">{{
              addressList[0].tel
            }}</i>
          </p>
          <p style="color: #666; font-size: 14px">
            {{ addressList[0].province }}{{ addressList[0].city
            }}{{ addressList[0].county }}{{ addressList[0].detail }}
          </p>
        </div>
      </div>
      <div
        class="address"
        @click="handlePopShow"
        v-if="addressList.length == 0 ? true : false"
      >
        <div class="no-address-con">
          <span>+</span>
          <router-link to="/ataddress">请添加地址</router-link>
        </div>
      </div>

      <div class="details">

        
        <div class="shopping" @click="good = true">
          <div
            class="img"
            v-for="(item, index) in goods"
            :key="index"
            style="display: inline-block; margin-top: 0.1rem"
          >
            <img :src="item.gtion.good_img" alt="" width="100%" />
          </div>

          <van-overlay :show="good"   >
            <div class="wrapper" @click.stop>
              <div class="block" >
               <div class="goods">
                 <li v-for="(item,index) in willBuy" :key="index">
                   <div class="img"> <img :src="item.gtion.good_img" alt=""></div>
                   <div class="good">
                     <p>{{item.gdetail.data.goods.name}}</p>
                     <p>{{item.gtion.good_price.min}}</p>
                   </div>

                 </li>
               </div>
               <div class="false" @click="good=false"></div>
              </div>
            </div>
          </van-overlay>
        </div>


        <div class="invoice">
          <span>优惠卷/提货卷/代金卷</span>
          <span class="coupon" @click="show=true">无可用> </span>

          <van-overlay :show="show" @click="show = false">
            <div class="wrapper" @click.stop>
              <div class="block" >
                <div class="ev-moudle"> 
                    优惠券/提货券/代金券
                </div>
                <div class="coupon-tab">
                  <span>可用优惠券(</span>
                  <span>提货券码/优惠券兑换码</span>
                  <span>代金券码</span>
                </div>
                <div class="list-empty">

                </div>
                <div class="shado">
                  <div class="item">
                    <span>已选择<span>0</span>张优惠卷</span>
                    <div><span>优惠</span><i>0.00</i></div>
                  </div>
                </div>
                <i @click="show=false"></i>
                </div>
            </div>
          </van-overlay>


        </div>
        <div class="invoice">
          <span>发票/服务等</span>
          <span class="coupon">不开发票></span>
        </div>
      </div>
      <div class="service"></div>
      <div class="remark">
        <div class="remark_title">订单备注</div>
        <input type="text" />
      </div>
      <div class="remark">
        <div class="flex">
          <span>活动</span>
          <span>满200减30</span>
        </div>
        <div class="flex"><span>商品金额</span><span>￥699</span></div>
        <div class="flex"><span>运费</span><span>包邮</span></div>
      </div>
    </section>
    <van-submit-bar :price="3050" button-text="提交订单" />

    <div class="model" v-if="model"></div>
    <div class="shipping-address" v-if="model">
      <div class="ez-model">选择收货地址</div>
      <div class="address-popup">
        <ul>
          <li v-for="(item, index) in addressList" :key="index">
            <div :class="item.isDefault?'bacg':'ys-checkbox__icon'" 
            @click="healselect(index)"></div>
            <div class="check-name">
              <p>
                <span class="img">
                  <img src="../assets/img/00dd.png" alt="" />
                </span>
                <span class="username">{{ item.name }}</span>
                <span class="prope">
                  {{ item.tel }}
                </span>
              </p>
              <div class="ellipis">
                {{ item.province }}{{ item.city }}{{ item.county }}
              </div>
            </div>
            <div class="deta" @click="handleClose(index)" >
              <img src="../assets/img/a404.png" alt="" />
            </div>
          </li>
        </ul>
      </div>
      <div class="shadow">
        <div class="shadown-a">
          <router-link to="/ataddress"> 新建地址</router-link>
        </div>
      </div>
      <i class="inconnet" @click="model = false"></i>
    </div>
  </div>
</template>

<script>
import { AddressList } from 'vant';
import axios from 'axios';
export default {
  data() {
    return {
      // checked: false,
      // checked1: false,
      isShow: true,
      model: false,
      show: false,
      goods: "",
      good: false,
      willBuy:null
    };
  },
  methods: {
    handlePopShow() {
      
    },
    healselect(j){
      let {addressList}=this
      for(let i=0;i<addressList.length;i++){
        this.addressList[i].isDefault=false
      }
      addressList[j].isDefault=true
    },
    handleHome(){
      this.$router.push('/home')
    }
  },
  computed: {
    addressList() {
      return this.$store.state.address.addressList;
    },
    waitShow(){
      return this.$store.state.huang.userData;
    }
  },
  created(){
    this.willBuy = this.$store.getters['huang/checkedGoods'];
    let { id } = this.$route.params
    this.det=id*100
    if(sessionStorage.userinfo){
      this.isLogin = true;
    }
  },
};
</script>

<style lang="less" scoped>
.false{
  width: 0.2rem;
  height: 0.2rem;
  position: absolute;
  top: 0.1rem;
  right: 0.25rem;
  background: #333;
  border-radius: 50%;
}
.goods{
  width: 3.45rem;
  height: 3.45rem;
  margin: 0.5rem auto;
  overflow-y: auto;
    li{
      width: 3.45rem;
      height: 1rem;
      display: flex;
        .img{
          width: 1rem;
          height: 1rem;
            img{
              width: 100%;
              height: 100%;
            }
        }
        .good{
          width: 2.45rem;
          height: 1rem;
            p{
                font-size: 0.14rem;
            }
        }
    }
}
.bacg{
  width: 0.22rem;
  height: 0.22rem;
  background: url('../assets/img/selected.png') no-repeat center;
  background-size: 100%;
  // background: yellow;
}
.wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    position: relative;
  }

  .block {
    position: absolute;
    bottom: 0;
    // width: 120px;
    width: 3.75rem;
    // height: 120px;
    height: 3.75rem;
    border-radius: 0.15rem;
    // z-index: 20;

    background-color: #fff;
      .ev-moudle{
        height: 0.38rem;
        padding: 0.2rem 0.3rem 0;
        box-sizing: border-box;
        color: #333;
        text-align: center;
        font-size: 18px;
        font-weight: bold;
      }
      .coupon-tab{
       height: 0.45rem;
       margin-top:0.15rem; 
        span{
          display: inline-block;
          padding: 0 0.05rem;
          margin: 0 0.09rem;
          font-size:13px;
          color: #333
        }
      }
      .list-empty{
        height: 2.25rem;
        padding: 0.52rem 0.15rem;
        box-sizing: border-box;
      }
      .shado{
        height: 0.6rem;
        padding: 0.1rem 0.15rem;
        box-sizing: border-box;
        position: absolute;
        bottom: 0;
        z-index: 100000000000;
        width: 3.75rem;
        
        background: #fff;
          .item{
            font-size: 12px;
            color:#333;
          }


      }
      i{
        display: inline-block;
        width: 0.2rem;
        height: 0.2rem;
        background: #333;
        position: absolute;
        top: 0.25rem;
        right: 0.2rem;
        border-radius: 50%;
      }
  }

@import url("../assets/css/CheckOut.css");
.van-cell-group {
  width: 3.45rem !important;
  margin: 0.1rem auto;
}
.model {
  width: 3.75rem;
  height: 6.67rem;
  background: rgba(0, 0, 0, 0.2);
  position: fixed;
  top: 0;
}
.shipping-address {
  width: 3.75rem;
  height: 3.9rem;
  background: #fff;
  position: fixed;
  bottom: 0;
  z-index: 100000;
  border-radius: 0.15rem 0.15rem 0 0;
  .shadow {
    position: absolute;
    bottom: 0;
    height: 0.64rem;
    padding: 0.1rem 0.15rem;
    box-sizing: border-box;
    .shadown-a {
      width: 3.45rem;
      height: 0.44rem;
      background: orange;
      border-radius: 0.22rem;
      padding: 0.14rem 0.2rem;
      box-sizing: border-box;
      text-align: center;
      a {
        color: #fff;
      }
    }
  }
  .inconnet {
    position: absolute;
    top: 0.15rem;
    right: 0.2rem;
    display: inline-block;
    width: 0.22rem;
    height: 0.22rem;
    border-radius: 50%;
    background: #999;
  }
  .ez-model {
    height: 0.38rem;
    padding: 0.2rem 0.3rem 0;
    box-sizing: border-box;
    text-align: center;
    color: #333;
    font-size: 18px;
    font-weight: bold;
  }
  .address-popup {
    max-height: 2.85rem;
    padding: 0.1rem 0.15rem 0.15rem;
    overflow-y: auto;
    ul {
      li {
        height: 0.8888rem;
        padding: 0.2rem 0;
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        align-items: center;
        .ys-checkbox__icon {
          width: 0.2rem;
          height: 0.2rem;
          border: 0.01rem solid #666;
        }
        .check-name {
          width: 2.42rem;
          height: 0.48rem;
          padding: 0 0.32rem 0 0.15rem;
          box-sizing: border-box;
          p {
            width: 1.95rem;
            height: 0.24rem;
            line-height: 0.24rem;
            .img {
              display: inline-block;
              width: 0.3rem;
              height: 0.16rem;
              border: 1px solid #333;
              img {
                width: 100%;
                height: 100%;
              }
            }
            .username {
              width: 0.58rem;
              height: 0.2rem;
              padding-right: 0.16rem;
              font-size: 16px;
              font-weight: bold;
              color: #333;
            }
            .prope {
              width: 0.9rem;
              height: 0.2rem;
              font-size: 14px;
              color: #333;
            }
          }
        }
        .deta {
          width: 0.2rem;
          height: 0.2rem;
          img {
            width: 100%;
            height: 100%;
          }
        }
      }
    }
  }
}
</style>
